package net.paruo.google.gwt.study_meeting.user_control.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;

public class UserDialogBox extends Composite {

	private static UserDialogBoxUiBinder uiBinder = GWT
			.create(UserDialogBoxUiBinder.class);

	interface UserDialogBoxUiBinder extends UiBinder<Widget, UserDialogBox> {
	}

	@UiField
	DialogBox dialog;
	@UiField
	HTML name;
	@UiField
	HTML mailAddress;
	@UiField
	Button btnClose;

	public UserDialogBox(UserData data) {
		initWidget(uiBinder.createAndBindUi(this));

		name.setHTML(data.getName());
		mailAddress.setHTML(data.getMailAddress());
		dialog.setText("ユーザ情報");
		dialog.setAnimationEnabled(true);
	}

	public void center() {
		dialog.center();
	}

	@UiHandler("btnClose")
	void onClick(ClickEvent e) {
		dialog.hide();
	}

}
